﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using WebVideo.Areas.Admin.Models;
namespace WebVideo.Areas.Admin.Controllers
{
    public class SupportStaffController : Controller
    {
        //
        // GET: /Admin/SupportStaff/

        public ActionResult Index()
        {
            return View(SupportStaffModel.Index());
        }

        #region "Insert"
        public ActionResult Insert()
        {
            SupportStaffModel ss = new SupportStaffModel();
            return View(ss);
        }

        [ValidateInput(false)]
        [HttpPost]
        public ActionResult Insert(SupportStaffModel ss)
        {

            try
            {
                if (ModelState.IsValid)
                {
                    SupportStaffModel.Insert(ss);
                    return RedirectToAction("Index", "SupportStaff");
                }
            }
            catch
            {

                return RedirectToAction("Index", "Error", new { errorMsg = "Lỗi SQL hosting / server" });
            }
            return View(ss);
        }
        #endregion //insert

        #region "Delete"

        public string Delete(int Id)
        {
            try
            {
                SupportStaffModel.Delete(Id);
                return "ok";
            }
            catch
            {
                return "error";
            }
        }
        #endregion //Delete

        #region "Edit"
        public ActionResult Edit(int IdSS)
        {


            return View(SupportStaffModel.LayModel(IdSS));

        }

        [ValidateInput(false)]
        [HttpPost]
        public ActionResult Edit(SupportStaffModel SS)
        {

            try
            {
                if (ModelState.IsValid)
                {
                    SupportStaffModel.Edit(SS);
                    return RedirectToAction("Index", "SupportStaff");
                }
            }
            catch
            {

                return RedirectToAction("Index", "Error", new { errorMsg = "Lỗi SQL hosting / server" });
            }
            return View(SS);
        }
        #endregion //Edit

    }
}
